from flask import Flask, render_template, request, redirect, url_for, session,Blueprint

class DefaultConfig(object):
    '''默认配置'''
    SECRET_KEY = 'asd331bkxa31ada12'

# 开发模式配置
class DevelopmentConfig(DefaultConfig):
    DEBUG = True
    FLASK_ENV = 'development'

# 生产模式配置
class ProductionConfig(DefaultConfig):
    DEBUG = False
    FLASK_ENV = 'production'

def create_flask_app(config):
    app = Flask(__name__)
    app.config.from_object(config)
    app.config.from_pyfile('settings.py')
    # app.config.from_envvar('SETTINGS')
    app.debug = app.config.get('DEBUG', False)
    return app

# app = create_flask_app(DefaultConfig)
# app = create_flask_app(DevelopmentConfig)
app = create_flask_app(ProductionConfig)

from goods import goods_bp
app.register_blueprint( goods_bp,url_prefix='/goods')



@app.route('/')
def index():
    print(app.config['SECRET_KEY'])
    return render_template('index.html')


if __name__ == '__main__':
    app.run()
